// Author: Domien Nowicki

#include "Cell.h"


Cell::Cell(unsigned int nMapX, unsigned int nMapY): empty(true), mapX(nMapX), mapY(nMapY)
{
	Clear();
}

Cell::Cell(const Cell& rhs): empty(rhs.empty), mapX(rhs.mapX), mapY(rhs.mapY)
{
	for(unsigned int i=0; i<SIDECOUNT; i++)
	{
		textures[i] = rhs.textures[i];
		userColors[i] = rhs.userColors[i];
	}
	
}

Cell::~Cell()
{
}

void Cell::Clear()
{
	// Set every texture to the "empty" texture, and clear the usercolors by making them transparent
	for(unsigned int i=0; i<SIDECOUNT; i++)
	{
		textures[i] = -1;
		userColors[i].SetTransparent();
	}
}


// Cell does not contain a wall (=is empty)?
bool Cell::IsEmpty() const
{
	return empty;
}

// Place wall inside cell
void Cell::SetWall()
{
	empty = false;
}

// Remove wall from cell
void Cell::SetEmpty()
{
	empty = true;

	Clear();
}

// Set a texture on a side, and its usercolor
void Cell::SetTexture(Cell::Side side, unsigned int tindex, const Pixel& userColor)
{
	textures[side] = tindex;
	userColors[side] = userColor;
}

// Get usercolor for a wall side
const Pixel& Cell::GetUserColor(Cell::Side side)
{
	return userColors[side];
}

// Get texture for a wall side
unsigned int Cell::GetTexture(Cell::Side side) const
{
	return textures[side];
}

// Set map position
void Cell::SetMapPos(unsigned int nMapX, unsigned int nMapY)
{
	mapX = nMapX;
	mapY = nMapY;
}

unsigned int Cell::GetMapX() const
{
	return mapX;
}

unsigned int Cell::GetMapY() const
{
	return mapY;
}


